package com.lcw.library.imagepicker.data;

import android.os.Parcel;

import com.lcw.library.imagepicker.imagelist.ImageUrlGetter;

/**
 * 媒体实体类 Create by: chenWei.li Date: 2018/8/22 Time: 上午12:36 Email: lichenwei.me@foxmail.com
 */
public class MediaFile implements ImageUrlGetter {

    private String path;
    private String mime;
    private Integer folderId;
    private String folderName;
    private long duration;
    private long dateToken;
    private boolean isAdd;//列表使用
    private int resId;//列表使用

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getMime() {
        return mime;
    }

    public void setMime(String mime) {
        this.mime = mime;
    }

    public Integer getFolderId() {
        return folderId;
    }

    public void setFolderId(Integer folderId) {
        this.folderId = folderId;
    }

    public String getFolderName() {
        return folderName;
    }

    public void setFolderName(String folderName) {
        this.folderName = folderName;
    }

    public long getDuration() {
        return duration;
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public long getDateToken() {
        return dateToken;
    }

    public void setDateToken(long dateToken) {
        this.dateToken = dateToken;
    }

    public boolean isAdd() {
        return isAdd;
    }

    public void setAdd(boolean add) {
        isAdd = add;
    }

    public int getResId() {
        return resId;
    }

    public void setResId(int resId) {
        this.resId = resId;
    }

    public MediaFile() {
    }

    public MediaFile(String path) {
        this.path = path;
    }

    public MediaFile(boolean isAdd, int resId) {
        this.isAdd = isAdd;
        this.resId = resId;
    }

    @Override
    public String getImageUrl() {
        return path;
    }

    @Override
    public int describeContents() { return 0; }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.path);
        dest.writeString(this.mime);
        dest.writeValue(this.folderId);
        dest.writeString(this.folderName);
        dest.writeLong(this.duration);
        dest.writeLong(this.dateToken);
        dest.writeByte(this.isAdd?(byte) 1:(byte) 0);
        dest.writeInt(this.resId);
    }

    protected MediaFile(Parcel in) {
        this.path = in.readString();
        this.mime = in.readString();
        this.folderId = (Integer) in.readValue(Integer.class.getClassLoader());
        this.folderName = in.readString();
        this.duration = in.readLong();
        this.dateToken = in.readLong();
        this.isAdd = in.readByte() != 0;
        this.resId = in.readInt();
    }

    public static final Creator<MediaFile> CREATOR = new Creator<MediaFile>() {
        @Override
        public MediaFile createFromParcel(Parcel source) {return new MediaFile(source);}

        @Override
        public MediaFile[] newArray(int size) {return new MediaFile[size];}
    };
}

